package net.sf.brutil.v0.server;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class SerializeUtil {

    
	  public static void serialize(String fileName,Object object){
		   try{
			   BufferedOutputStream fileOutputStream=new BufferedOutputStream(new FileOutputStream(fileName));
			   ObjectOutputStream objectOutputStream=new ObjectOutputStream(fileOutputStream);
			   objectOutputStream.writeObject(object);
			   objectOutputStream.close();
		   } catch (Exception e){
			   throw new RuntimeException(e);
		   }
	   }
	   
	   
	   
	   public static  Object unserialize(String fileName){
		   try{
			   InputStream fileInputStream=new BufferedInputStream(new FileInputStream(fileName));
			   ObjectInputStream objectInputStream=new ObjectInputStream(fileInputStream);
			   Object retVal=objectInputStream.readObject();
			   objectInputStream.close();
			   return retVal;
		   } catch (Exception e){
			   throw new RuntimeException(e);
		   }
	   }
}
